package at.fhj.itm10.ticketmaster.dao.datasource;

import java.io.File;

import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;

/**
 * "resource.xml" checker for people which do not get it to
 * read the README files.
 * 
 * @author Wolfgang Gaar
 */
public class ResourceXmlChecker {

	public ResourceXmlChecker() throws Exception {
		ServletContext servletContext = (ServletContext) FacesContext
				.getCurrentInstance().getExternalContext().getContext();
		String path = servletContext.getRealPath("/") + "WEB-INF/resources.xml";
		
		boolean exists = new File(path).exists();

		System.out.println("checking for resources.xml");
		System.out.println("resources.xml: " + path);
		System.out.println("resources.xml exists: " + exists);

		if (!exists) {
			throw new WhyYouNoReadTheReadmeException();
		}
	}

}
